package com.navi.loaddata.loadService.impl.measureData.cell2;

import com.navi.loaddata.core.gpEntity.GpDefectF;
import com.navi.loaddata.core.gpEntity.GpGlassF;
import com.navi.loaddata.core.gpEntity.MppLayoutPnlD;
import com.navi.loaddata.core.mesEntity.MesProductEntity;
import com.navi.loaddata.core.mysqlEntity.EdaMeasureDefecttypeD;
import com.navi.loaddata.core.oracleEntity.EtlDefectV;
import com.navi.loaddata.core.oracleEntity.EtlGlassV;
import com.navi.loaddata.core.repository.impl.MesRepositoryImpl;
import com.navi.loaddata.core.util.CoordTransformService;
import com.navi.loaddata.core.util.CorrdTransformException;
import com.navi.loaddata.core.util.LoggerUtil;
import com.navi.loaddata.core.util.ProcessUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author jay
 */
@Service
public class ProcessDefectDataServiceCELL2 {
    @Autowired
    private CoordTransformService coordTransformService;
    @Autowired
    private MesRepositoryImpl daomes;
    private static final Logger logger = LoggerFactory.getLogger(ProcessDefectDataServiceCELL2.class);


    public List<EtlGlassV> processGlass(GpGlassF glass) throws Exception {
        List<EtlGlassV> etlGlassVList = new ArrayList<>();
        EtlGlassV glassEntity = new EtlGlassV();

//            if ("L".equals(glass.getOpeId().substring(0,1))) {
        glassEntity.setStepId(ProcessUtil.processString(glass.getOpeId()));
//            }else {
//                glassEntity.setStepId(ProcessUtil.processString("L"+glass.getOpeId()));
//            }
//            glassEntity.setGlassId(ProcessUtil.processString(glass.getGlassId()));
        glassEntity.setChipId(ProcessUtil.processString(glass.getGlassId()));
        glassEntity.setGlassId(ProcessUtil.processString(glass.getGlassId().substring(0, 10)));
        Date procEndTime = new Date(glass.getProcEndTime().getTime());
        glassEntity.setGlassEndTime(procEndTime);
        if (!StringUtils.isEmpty(glass.getProcStartTime())) {
            glassEntity.setGlassStartTime(new Date(glass.getProcStartTime().getTime()));
        }
        glassEntity.setProductId(ProcessUtil.processString(glass.getProdId()));
        glassEntity.setProductVersion(null);
        glassEntity.setRouteId(null);
        glassEntity.setLotId(ProcessUtil.processString(glass.getLotId()));
        glassEntity.setEquipId(ProcessUtil.processString(glass.getEqptId()));
        glassEntity.setRunMode(null);
        glassEntity.setRecipeId(ProcessUtil.processString(glass.getRecipeId()));
        glassEntity.setSubEquipId(null);
        glassEntity.setOperatorId(ProcessUtil.processString(glass.getOperatorId()));
        glassEntity.setCstId(ProcessUtil.processString(glass.getCrrId()));

        glassEntity.setTaShift(glass.getShfId());

        glassEntity.setLotType(ProcessUtil.processString(glass.getLotType()));
        glassEntity.setOwnerId(ProcessUtil.processString(glass.getOwner()));
        //  glassEntity.setOwnerType(); //待处理
        glassEntity.setSlotNo(ProcessUtil.processString(glass.getSlotNo()));
        glassEntity.setAbnormalFlag(ProcessUtil.processString(glass.getAbnFlg()));
        glassEntity.setMesLinkKry(ProcessUtil.processString(glass.getMesLinkKey()));
        // glassEntity.setSamplingFlag(); //待处理
        glassEntity.setGlassJudge(ProcessUtil.processString(glass.getGlassJge()));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = glass.getProcEndTime();
        Date date2 = glass.getProcStartTime();
        glassEntity.setProcessTime(date1.getTime() - date2.getTime());
        glassEntity.setTactTime(ProcessUtil.getNumI(glass.getTactTime()));
        glassEntity.setTotalDftCount(ProcessUtil.getNumI(glass.getGlassDefectCnt()));
        glassEntity.setTotalImageCount(ProcessUtil.getNumI(glass.getGlassImgCnt()));
        //  glassEntity.setTotalReprDftQty(); //待处理
        glassEntity.setLcvdReprDftQty(ProcessUtil.getNumI(glass.getGlassLcvdRepDefectCnt()));
        glassEntity.setBackSideDftQty(ProcessUtil.getNumI(glass.getGlassBackDefectCnt()));
        glassEntity.setTestKetDftQty(ProcessUtil.getNumI(glass.getGlassTestKeyDefectCnt()));
        glassEntity.setAftStkDftQty(ProcessUtil.getNumI(glass.getGlassAfterStackDefectCnt()));
        glassEntity.setInkReprDftQty(ProcessUtil.getNumI(glass.getGlassInkRepDefectCnt()));
        glassEntity.setPnlCapDftQty(ProcessUtil.getNumI(glass.getGlassCaptureDefectCnt()));
        glassEntity.setTapReprDftQty(ProcessUtil.getNumI(glass.getGlassTapeRepDefectCnt()));
        glassEntity.setLsrReprDftQty(ProcessUtil.getNumI(glass.getGlassLaserRepDefectCnt()));
        glassEntity.setoDftQty(ProcessUtil.getNumI(glass.getGlassOSizeCnt()));
        glassEntity.setlDftQty(ProcessUtil.getNumI(glass.getGlassLSizeCnt()));
        glassEntity.setmDftQty(ProcessUtil.getNumI(glass.getGlassMSizeCnt()));
        glassEntity.setsDftQty(ProcessUtil.getNumI(glass.getGlassSSizeCnt()));
        glassEntity.setBrightDftQty(ProcessUtil.getNumI(glass.getGlassBrightDefectCnt()));
        glassEntity.setWriteDftQty(ProcessUtil.getNumI(glass.getGlassWhiteDefectCnt()));
        glassEntity.setGrayDftQty(ProcessUtil.getNumI(glass.getGlassGrayDefectCnt()));
        glassEntity.setBlackDftQty(ProcessUtil.getNumI(glass.getGlassDarkDefectCnt()));
        glassEntity.setScanAlignMark1Flg(ProcessUtil.getNum(glass.getScanAlignMark1Flg()));
        glassEntity.setScanAlignMark2Flg(ProcessUtil.getNum(glass.getScanAlignMark2Flg()));
        glassEntity.setScanAlignMark1X(ProcessUtil.getNum(glass.getScanAlignMark1XCoord()));
        glassEntity.setScanAlignMark1Y(ProcessUtil.getNum(glass.getScanAlignMark1YCoord()));
        glassEntity.setScanAlignMark2X(ProcessUtil.getNum(glass.getScanAlignMark2XCoord()));
        glassEntity.setScanAlignMark2Y(ProcessUtil.getNum(glass.getScanAlignMark2YCoord()));
        glassEntity.setCaptureAlignMark1Flg(ProcessUtil.getNum(glass.getCaptureAlignMark1Flg()));
        glassEntity.setCaptureAlignMark2Flg(ProcessUtil.getNum(glass.getCaptureAlignMark2Flg()));
        glassEntity.setCaptureAlignMark1X(ProcessUtil.getNum(glass.getCaptureAlignMark1XCoord()));
        glassEntity.setCaptureAlignMark1Y(ProcessUtil.getNum(glass.getCaptureAlignMark1YCoord()));
        glassEntity.setCaptureAlignMark2X(ProcessUtil.getNum(glass.getCaptureAlignMark2XCoord()));
        glassEntity.setCaptureAlignMark2Y(ProcessUtil.getNum(glass.getCaptureAlignMark2YCoord()));
        glassEntity.setResolRvHead1(ProcessUtil.processString(glass.getRewHeadResolution1()));
        glassEntity.setResolRvHead2(ProcessUtil.processString(glass.getRewHeadResolution2()));
        glassEntity.setResolRvHead3(ProcessUtil.processString(glass.getRewHeadResolution3()));
        glassEntity.setResolRvHead4(ProcessUtil.processString(glass.getRewHeadResolution4()));
        glassEntity.setResolRvHead5(ProcessUtil.processString(glass.getRewHeadResolution5()));
        glassEntity.setResolRvHead6(ProcessUtil.processString(glass.getRewHeadResolution6()));
        glassEntity.setCaptureSize(ProcessUtil.processString(glass.getCaptureSize()));
        glassEntity.setProbeCardId(ProcessUtil.processString(glass.getProbeCardId()));
        glassEntity.setGlassGrade(ProcessUtil.processString(glass.getGlassGrade()));
        glassEntity.setTrtrCode(ProcessUtil.processString(glass.getGlassRejCode()));
        glassEntity.setChipNo(ProcessUtil.processString(glass.getGlassId().substring(glass.getGlassId().length() - 2, glass.getGlassId().length())));
        glassEntity.setArrayGlassId(ProcessUtil.processString(glass.getGlassId().substring(0, 10)));
        List<MesProductEntity> CfGlassIdList = daomes.find(MesProductEntity.class, "from MesProductEntity where productname='" + glass.getGlassId() + "'");
        String CfGlassId = null;
        if (null != CfGlassIdList && CfGlassIdList.size() > 0) {
            CfGlassId = CfGlassIdList.get(0).getCfproductname();
        }
        glassEntity.setCfGlassId(ProcessUtil.processString(CfGlassId));

        if (!StringUtils.isEmpty(glass.getRewkCnt())) {
            glassEntity.setReworkCnt(String.valueOf(glass.getRewkCnt()));
        } else {
            glassEntity.setReworkCnt("-1");
        }
        etlGlassVList.add(glassEntity);

        return etlGlassVList;
    }


    public List<EtlDefectV> processDefect(List<MppLayoutPnlD> layoutPnlDS, List<GpDefectF> gpDefectFList, Map<String, String> mOpeDList, HashMap<String, EdaMeasureDefecttypeD> defectCodeMap) throws Exception {
        List<EtlDefectV> etlDefectVList = new ArrayList<>();

        gpDefectFList.forEach(defect -> {
            EtlDefectV defectEntity = new EtlDefectV();
//                if ("L".equals(defect.getOpeId().substring(0,1))) {
            defectEntity.setStepId(ProcessUtil.processString(defect.getOpeId()));
//                }else {
//                    defectEntity.setStepId(ProcessUtil.processString("L"+defect.getOpeId()));
//                }
//                defectEntity.setComponentId(ProcessUtil.processString(defect.getGlassId()));

            Date procEndTime = new Date(defect.getProcEndTime().getTime());
            defectEntity.setGlassEndTime(procEndTime);
            defectEntity.setDefectNo(String.valueOf(defect.getPanelId() + ProcessUtil.getLength4(defect.getDefectNo())));
            defectEntity.setGlassId(ProcessUtil.processString(defect.getGlassId()));
            defectEntity.setChipId(ProcessUtil.processString(defect.getPanelId()));
//                defectEntity.setChipNo(defect.getPanelId().substring(defect.getPanelId().length() - 2, defect.getPanelId().length()));
//                ldrArrayDefectTEntity.setItem1(defect.getrejecttype);
//                ldrArrayDefectTEntity.setDefectCode(defect.getcode);
            //item3
            String NASPath = "";
            String IMGPath = "";
            String[] listItem3 = defect.getFileUrl().split("\\\\");
            if (listItem3[0] == "") {

            } else {
//                NASPath = listItem3[0] + "\\" + listItem3[1] + "\\";//实际NAS路径
                NASPath = "IMG;/acf;/";
                switch (defect.getShopId()) {
                    case "ARRAY":
                        if (!StringUtils.isEmpty(defect.getDefectImg()) && defect.getDefectImg().indexOf("*") == -1) {//彩照
                            if ("A775".equals(defect.getOpeId().substring(0, 4)) && "ATST".equals(mOpeDList.get(defect.getOpeId()))) {
                                IMGPath = "LCVD/IMAGES/" + defect.getLotId().substring(0, 5) + "/" + defect.getLotId() + "/" + defect.getDefectImg() + ".JPG";
                            } else if ("A770".equals(defect.getOpeId().substring(0, 4)) && "ATST".equals(mOpeDList.get(defect.getOpeId()))) {
                                IMGPath = "REPR/IMAGES/" + defect.getLotId().substring(0, 5) + "/" + defect.getLotId() + "/" + defect.getDefectImg() + ".JPG";
                            } else {//正常
                                if ("AOI".equals(mOpeDList.get(defect.getOpeId()))) {
                                    IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                            + defect.getGlassId() + "/IMAGE/" + defect.getDefectImg() + ".JPG";
                                } else if ("ATST".equals(mOpeDList.get(defect.getOpeId()))) {
                                    IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                            + defect.getGlassId() + "/IMAGE/" + defect.getDefectImg() + ".JPG";
                                } else if ("LOI".equals(mOpeDList.get(defect.getOpeId()))) {
                                    IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                            + defect.getGlassId() + "/IMAGE/" + defect.getDefectImg() + ".JPG";
                                }
                            }
                            defectEntity.setImageData(NASPath + IMGPath);
                        }
                        if (!StringUtils.isEmpty(defect.getGrayImgName()) && defect.getGrayImgName().indexOf("*") == -1) {//灰阶
                            IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                    + defect.getGlassId() + "/GRAYIMAGE/" + defect.getGrayImgName() + ".JPG";
                            defectEntity.setGrayimageData(NASPath + IMGPath);
                        }
                        break;
                    case "CF":
                        if (!StringUtils.isEmpty(defect.getDefectImg()) && defect.getDefectImg().indexOf("*") == -1) {//彩照
//                            if("A775".equals(defect.getOpeId().substring(0,4)) && "ATST".equals(mOpeDList.get(defect.getOpeId()))){
//                                IMGPath = "LCVD/IMAGES/" + defect.getLotId().substring(0, 5) + "/" + defect.getLotId() + "/ARRAYATST;" + defect.getDefectImg() + ".JPG";
//                            }else if(defect.getOpeId().substring(0,4)=="A770" && "ATST".equals(mOpeDList.get(defect.getOpeId()))){
//                                IMGPath = "REPR/IMAGES/" + defect.getLotId().substring(0, 5) + "/" + defect.getLotId() + "/ARRAYATST;" + defect.getDefectImg() + ".JPG";
//                            }else{//正常
                            if ("AOI".equals(mOpeDList.get(defect.getOpeId()))) {
                                IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                        + defect.getGlassId() + "/IMAGE/" + defect.getDefectImg() + ".JPG";
                            } else if ("ATST".equals(mOpeDList.get(defect.getOpeId()))) {
                                IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                        + defect.getGlassId() + "/IMAGE/" + defect.getDefectImg() + ".JPG";
                            } else if ("LOI".equals(mOpeDList.get(defect.getOpeId()))) {
                                IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                        + defect.getGlassId() + "/IMAGE/" + defect.getDefectImg() + ".JPG";
//                                }
                            }
                            defectEntity.setImageData(NASPath + IMGPath);
                        }
                        if (!StringUtils.isEmpty(defect.getGrayImgName()) && defect.getGrayImgName().indexOf("*") == -1) {//灰阶
                            IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                    + defect.getGlassId() + "/GRAYIMAGE/" + defect.getGrayImgName() + ".JPG";
                            defectEntity.setGrayimageData(NASPath + IMGPath);
                        }
                        if (!StringUtils.isEmpty(defect.getBefRvrpImgName()) && defect.getBefRvrpImgName().indexOf("*") == -1) {//修补前
                            IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                    + defect.getGlassId() + "/IMAGE/" + defect.getBefRvrpImgName() + ".JPG";
                            defectEntity.setBeforeRvrpImageName(NASPath + IMGPath);
                        }
                        if (!StringUtils.isEmpty(defect.getAftRvrpImgName()) && defect.getAftRvrpImgName().indexOf("*") == -1) {//修补后
                            IMGPath = defect.getProdId() + "/" + defect.getGlassId().substring(0, 5) + "/" + defect.getGlassId().substring(0, 8) + "/"
                                    + defect.getGlassId() + "/IMAGE/" + defect.getAftRvrpImgName() + ".JPG";
                            defectEntity.setAfterRvrpImageName(NASPath + IMGPath);
                        }
                        break;
                    case "OC":
                        break;
//                    default:
//                        defectEntity.setImageData(NASPath);
//                        break;
                }
            }
            defectEntity.setDefectType("other");   //待处理
            defectEntity.setDefectCode(defect.getDefectCode()); //待处理
            // defectEntity.setImageData(); //上面已处理
            // defectEntity.setGrayimageData(); //上面已处理
            //  defectEntity.setAutoDefectCode();  //待处理
            //   defectEntity.setReason();  //待处理
            //  defectEntity.setMainDefectFlag(); //待处理
            //4-7
            defectEntity.setCellZone(ProcessUtil.processString(defect.getDefectZong()));      //zone      ??????
            defectEntity.setX(ProcessUtil.getNum(defect.getDefectXCoord()));
            defectEntity.setY(ProcessUtil.getNum(defect.getDefectYCoord()));
            // defectEntity.setX2();
            // defectEntity.setY2();
            //  defectEntity.setX3();
            // defectEntity.setY3();
            //numtitem3-6
            defectEntity.setS(ProcessUtil.getNum(defect.getDataNo()));
            defectEntity.setG(ProcessUtil.getNum(defect.getGateNo()));
            defectEntity.setDefSize(ProcessUtil.processString(defect.getDefectSize()));
            defectEntity.setSizeX(ProcessUtil.getNum(defect.getDefectXSize()));
            defectEntity.setSizeY(ProcessUtil.getNum(defect.getDefectYSize()));
            //  defectEntity.setDefectPattern();  //待处理
            defectEntity.setCcdid(ProcessUtil.processString(defect.getCcdId()));
            defectEntity.setOperatorIdRepr(ProcessUtil.processString(defect.getOperatorId()));
            defectEntity.setDefectFlag(ProcessUtil.processString2(defect.getDefectFlg()));
            defectEntity.setDefZone(ProcessUtil.processString(defect.getDefectZong()));
            defectEntity.setDefGrayLevelMax(ProcessUtil.getNum(defect.getAoiDefectGrayMax()));
            defectEntity.setDefGrayLevelMin(ProcessUtil.getNum(defect.getAoiDefectGrayMin()));
            defectEntity.setDefGrayLevelAvg(ProcessUtil.getNum(defect.getAoiDefectGrayAvg()));
            defectEntity.setDefGrayLevelRef(ProcessUtil.getNum(defect.getAoiDefectGrayRef()));
            defectEntity.setAdjPixelX(ProcessUtil.getNum(defect.getAdjXMuraVal()));
            defectEntity.setAdjPixelY(ProcessUtil.getNum(defect.getAdjYVcomLvl()));
            defectEntity.setAdjDftAreaSize(ProcessUtil.getNum(defect.getDefectAreaSize()));
            defectEntity.setAdjDftSizeX(ProcessUtil.getNum(defect.getAdjDefectXSize()));
            defectEntity.setAdjDftSizeY(ProcessUtil.getNum(defect.getAdjDefectYSize()));
            defectEntity.setDefZone(ProcessUtil.processString(defect.getDefectZong()));
            defectEntity.setAlarmTestKeyNo(ProcessUtil.getNum(defect.getAlarmTstKeyNo()));
            defectEntity.setInspections(ProcessUtil.processString(defect.getInspFlg()));
            defectEntity.setBeforeTapeValue(ProcessUtil.processString(defect.getBefTapeVal()));
            defectEntity.setAfterTapeValue(ProcessUtil.processString(defect.getAfterTapeVal()));
            //  defectEntity.setGrayDftQty(); //待处理
            defectEntity.setAoiDftImgName(ProcessUtil.processString(defect.getAoiDefectImgName()));
            // defectEntity.setBeforeRvrpImageName(ProcessUtil.processString(defect.getBefRvrpImgName()));//上面已处理
            //  defectEntity.setAfterRvrpImageName(ProcessUtil.processString(defect.getAftRvrpImgName()));  //上面已处理
            defectEntity.setBeforeInrpImageName(ProcessUtil.processString(defect.getBefInrpImgName()));
            defectEntity.setAfterInrpImageName(ProcessUtil.processString(defect.getAftInrpImgName()));
            //defectEntity.setRejudgeFlag();  //待处理
            //defectEntity.setDefectGlAve();  //待处理
            defectEntity.setTesterDefType1(ProcessUtil.processString(defect.getTestDefType1()));
            defectEntity.setTesterDefType2(ProcessUtil.processString(defect.getTestDefType2()));
            defectEntity.setDefResetFlg(ProcessUtil.processString(defect.getDefRetestFlg()));
            defectEntity.setRepairLineNo(ProcessUtil.processString(defect.getRepLineFlg()));
            defectEntity.setDefRealSize(ProcessUtil.processString(defect.getDefectAreaSize()));
            defectEntity.setDefLayer(ProcessUtil.processString(defect.getDefLayer().toString()));
            defectEntity.setLcvdRepairTime(ProcessUtil.processString(defect.getLcvdRepTime().toString()));
            defectEntity.setLcvdLen(ProcessUtil.processString(defect.getLcvdLength().toString()));
            defectEntity.setOperationId(ProcessUtil.processString(defect.getOperationId()));
            defectEntity.setLcvdType(ProcessUtil.processString(defect.getLcvdType()));
            // defectEntity.setReserved1();  //预留
            // defectEntity.setReserved2();   //预留
            defectEntity.setDefPictName(ProcessUtil.processString(defect.getDefImgName()));
            defectEntity.setAnalysModeCode(ProcessUtil.processString(defect.getAnalysisCode()));


            if (!StringUtils.isEmpty(layoutPnlDS)) {
                try {
                    Map<String, Double> dgLines = coordTransformService.small2big(defect.getPanelId(), Integer.valueOf(defect.getPanelId().substring(defect.getPanelId().length() - 2, defect.getPanelId().length())), layoutPnlDS, ProcessUtil.getDouble(defect.getDataNo()), ProcessUtil.getDouble(defect.getGateNo()));
//                        logger.info("panelId={}存在layout,arrayX={},arrayY={}",defect.getPanelId(),dgLines.get("glassX"),dgLines.get("glassY"));
                    defectEntity.setArrayX(ProcessUtil.getNum(dgLines.get("glassX")));
                    defectEntity.setArrayY(ProcessUtil.getNum(dgLines.get("glassY")));
                    defectEntity.setArrayPanelS(dgLines.get("data"));
                    defectEntity.setArrayPanelG(dgLines.get("gate"));


                } catch (CorrdTransformException e) {
                    logger.warn("defectNo=" + defect.getDefectNo() + " opeId=" + defect.getOpeId() + " procEndTime=" + defect.getEvtTimestamp() + ":" + e.getErrorCode());
                } catch (Exception e) {
                    logger.warn("defectNo=" + defect.getDefectNo() + " opeId=" + defect.getOpeId() + " procEndTime=" + defect.getEvtTimestamp() + ":" + LoggerUtil.stackTraceToString(e));
                }
            } else {
//                    logger.info("panelId={}不存在layout!",defect.getPanelId());
                defectEntity.setArrayX(Long.valueOf(0));
                defectEntity.setArrayY(Long.valueOf(0));
                defectEntity.setArrayPanelS(0.0);
                defectEntity.setArrayPanelG(0.0);
            }
            String type = "POINT";
            String orientation = null;
            String sG = null;
            if (!StringUtils.isEmpty(defect.getDefectCode()) && null != defectCodeMap.get("CELL2_" + defect.getDefectCode())) {
                type = defectCodeMap.get("CELL2_" + defect.getDefectCode()).getType();
                orientation = defectCodeMap.get("CELL2_" + defect.getDefectCode()).getOrientation();
                sG = defectCodeMap.get("CELL2_" + defect.getDefectCode()).getsG();
            }
            HashMap<String, String> defectTypeMap = coordTransformService.getDefectTypeMap(defect.getPanelId(), Integer.valueOf(defect.getPanelId().substring(defect.getPanelId().length() - 2, defect.getPanelId().length())), layoutPnlDS,defectEntity.getS(), defectEntity.getG(), type, orientation, sG);
            defectEntity.setMarkTypeSg(defectTypeMap.get("TYPE"));
            defectEntity.setArrayPanelS1(ProcessUtil.getStr2Long(defectTypeMap.get("PanelS1")));
            defectEntity.setArrayPanelG1(ProcessUtil.getStr2Long(defectTypeMap.get("PanelG1")));
            defectEntity.setArrayPanelS2(ProcessUtil.getStr2Long(defectTypeMap.get("PanelS2")));
            defectEntity.setArrayPanelG2(ProcessUtil.getStr2Long(defectTypeMap.get("PanelG2")));


            etlDefectVList.add(defectEntity);
        });
        return etlDefectVList;
    }



}
